package com.example.radiationarea.block;

import com.example.radiationarea.effect.ModEffects;
import net.minecraft.core.BlockPos;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;

public class RadioactiveBlock extends Block {
    public RadioactiveBlock(Properties properties) {
        super(properties);
    }

    @Override
    public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) {
        if (!level.isClientSide && entity instanceof LivingEntity livingEntity) {
            // Only apply radiation effect to players, monsters are immune
            if (livingEntity instanceof Player) {
                // Apply radiation effect, lasting 400 ticks (20 seconds)
                livingEntity.addEffect(new MobEffectInstance(ModEffects.RADIATION.get(), 400, 0));
            }
        }
        super.stepOn(level, pos, state, entity);
    }
}